﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using GameSchool.Models;
using System.IO;
using System.Diagnostics;


namespace GameSchool.Controllers
{
	[Authorize]
    public class HomeController : Controller
    {
        GameRepository repository = new GameRepository();
		public ActionResult Index()
        {
			AnnouncementRepository repository = new AnnouncementRepository();
            //Aðeins umsjónarmaður sér nýjustu 3 tilkynningar
			if (User.IsInRole("Admin") || User.IsInRole("Teacher"))
			{
				var items = (from n in repository.Announcements()
							orderby n.Date descending
							select n).Take(3);
				return View(items);
			}
			else if (User.IsInRole("Student"))
			{
				return RedirectToAction("Games","Game");
			}
			else
			{
				return RedirectToAction("NoPrivileges","Home");
			}
        }

		public ActionResult WebStore()
		{
			ViewBag.Message = "Vefbúð";
			return View();
		}
    }
}
